Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P2P: give the protocol handler access to the peer info #302

Merged
merged 11 commits into from
Sep 30, 2024
Merged

Conversation

Boog900
Copy link
Member

@Boog900 Boog900 commented Sep 27, 2024

What

Changes the p2p crates to allow giving the protocol handler access to the peer info.

Why

It is useful to know the peers sync state when handling protocol requests.

Where

Mainly the handshaker/handshaker builder.

How

Uses the tower::make::* stuff, this allows us to provide an async interface for creating request handlers, which is going to be useful for validating core sync data when handshaking is complete

@github-actions github-actions bot added A-p2p Related to P2P. A-dependency Related to dependencies, or changes to a Cargo.{toml,lock} file. A-workspace Changes to a root workspace file or general repo file. labels Sep 27, 2024
@Boog900 Boog900 marked this pull request as ready for review September 30, 2024 18:44
Cargo.toml Outdated Show resolved Hide resolved
Comment on lines -63 to +68
protocol_request_svc: DummyProtocolRequestHandler,
protocol_request_svc_maker: MapErr::new(
Shared::new(DummyProtocolRequestHandler),
tower::BoxError::from,
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This infallible is being wrapped and returned in an error to satisfy trait bounds, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Co-authored-by: hinto-janai <hinto.janai@protonmail.com>
Copy link
Member Author

@Boog900 Boog900 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow I forgot to comment this

Cargo.toml Outdated
tower = { version = "0.4.13", default-features = false }
tower = { git = "https://github.com/Cuprate/tower.git", rev = "6c7faf0", default-features = false }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to fix a bug in tower so until they merge the patch we will need to point to this fork.

Comment on lines +283 to +293
pub trait ProtocolRequestHandlerMaker<Z: NetworkZone>:
tower::MakeService<
client::PeerInformation<Z::Addr>,
ProtocolRequest,
MakeError = tower::BoxError,
Service: ProtocolRequestHandler,
Future: Send + 'static,
> + Send
+ 'static
{
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new trait alias and updated the others to use trait bounds instead of an extra associated type

Comment on lines +196 to +197
/// Changes the protocol request handler maker, which creates the service that handles [`ProtocolRequest`](crate::ProtocolRequest)s
/// to our node.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handshaker now takes a protocol request handler maker instead of just the request hander

Comment on lines -63 to +68
protocol_request_svc: DummyProtocolRequestHandler,
protocol_request_svc_maker: MapErr::new(
Shared::new(DummyProtocolRequestHandler),
tower::BoxError::from,
),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@Boog900 Boog900 merged commit 521bf87 into main Sep 30, 2024
7 of 8 checks passed
@Boog900 Boog900 deleted the proto-handler branch September 30, 2024 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dependency Related to dependencies, or changes to a Cargo.{toml,lock} file. A-p2p Related to P2P. A-workspace Changes to a root workspace file or general repo file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants